package Filter.impl;

import Filter.service.Criteria;
import Filter.entity.Person;
import lombok.AllArgsConstructor;

import java.util.List;

/**
 * @author chengjunjie
 * @date 2025-09-10
 */

@AllArgsConstructor
public class OrCriteria implements Criteria {

    Criteria one;
    Criteria two;

    @Override
    public List<Person> filter(List<Person> personList) {
        List<Person> first = one.filter(personList);
        List<Person> second = two.filter(personList);
        for (Person p : personList) {
            if (!second.contains(p)) {
                first.add(p);
            }
        }
        return first;
    }
}
